package whf.framework.web.query;

import whf.framework.util.StringUtils;

/**
 * @author wanghaifeng
 *
 */
public class DateField extends Field{
	public DateField(String name, String[] values){
		super(name, values);
	}
	
	@Override
	public String toHQLString() {
		StringBuilder sb = new StringBuilder("(");
		if(!StringUtils.isEmpty(values[0]))
			sb.append("t.").append(name).append(">='").append(values[0]).append("'");
		if(values.length == 2 && !StringUtils.isEmpty(values[1])){
			if(!"(".equals(sb.toString()))
				sb.append(" and ");
			sb.append("t.").append(name).append("<='").append(values[1]).append("'");
		}
		sb.append(")");
		return sb.toString();
	}

}
